<?php

namespace apiend\modules\book\models;

use Yii;

/**
 * BookSearch is the model class for table "{{%book}}".
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class BookStaffSearch extends \common\models\book\BookStaff {

    /**
     * Searching member apply
     * @param  array $params
     * @return \yii\data\ActiveDataProvider
     */
    public function buildQuery($params = []) {
        $query = static::find()->active();
        $query->andFilterWhere([
            'book_id' => $this->book_id
        ]);
        if (!empty($params)) {
            $query->andFilterWhere($params);
        }
        return $query;
    }

    /**
     * {@inheritdoc}
     */
    public function fieldConfigs() {
        return [
            [
                'attribute' => 'id',
                'headerOptions' => ['width' => 80],
            ],
            'realname',
            'position',
            'mobile',
            'company_name',
            [
                'class' => 'common\rest\grid\ActionColumn',
                'template' => '{update}{delete}',
                'headerOptions' => ['width' => '120'],
            ],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function configs() {
        return [
            'dialog' => [
                'visible' => false,
                'title' => '预约参观人员'
            ],
            'config' => [
                'gridConfig' => $this->options(),
            ]
        ];
    }

}
